language: cpp

before_install:
 - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
 - sudo apt-get update -qq
 - sudo apt-get install -qq libcurl4-openssl-dev libjsoncpp-dev libargtable2-dev libgnutls-dev libgcrypt11-dev valgrind wget gcc-4.8 g++-4.8
 - wget http://ftp.gnu.org/gnu/libmicrohttpd/libmicrohttpd-0.9.44.tar.gz
 - tar -xvf libmicrohttpd-0.9.44.tar.gz
 - cd libmicrohttpd-0.9.44
 - ./configure && make
 - sudo make install && sudo ldconfig
 - cd .. && sudo rm -rf libmicrohttpd-0.9.44
 - sudo pip install cpp-coveralls
 -  sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
 -  sudo apt-get update -qq
 -  if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; fi
 -  if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi

install:
  - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi

env:
 - HTTP_SERVER=YES HTTP_CLIENT=YES COMPILE_STUBGEN=YES

compiler:
  - gcc

script: 
    - mkdir -p build && cd build
    - cmake -DCMAKE_BUILD_TYPE=Debug -DHTTP_CLIENT=${HTTP_CLIENT} -DHTTP_SERVER=${HTTP_SERVER} -DCOMPILE_STUBGEN=${COMPILE_STUBGEN} .. 
    - make
    - make test
    - sudo make install && sudo ldconfig
    - g++ ../src/examples/simpleclient.cpp -ljsonrpccpp-client -ljsoncpp -ljsonrpccpp-common -lcurl -o sampleclient
    - g++ ../src/examples/simpleserver.cpp -ljsonrpccpp-server -ljsoncpp -ljsonrpccpp-common -lmicrohttpd -o sampleserver
    - sudo make uninstall
after_success:
    - cd ..
    - coveralls -e src/test -e src/examples -e cmake -e /usr/include -e build/CMakeFiles -E '.*\.h' -E 'libmicrohttpd.*'
